<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$USER = getAccountUserObject();
		
?>
<style>

#wrap-contactus{float:left;width:420px;margin-top:10px;margin-bottom:20px;margin-left:0px;}
	
.wrap-input{float:left;width:100%;clear:both;margin:3px 0px;}

.wrap-input .text-label{
	float:left;width:150px;display:block;min-height:15px;
}
.wrap-input .input-field{
	float:left;width:250px;display:block;
	padding-left:5px;
}

.input-field input{width:200px;}

.input-field input.button{width:auto!important;padding:0px 10px;}

textarea.message{width:350px;height:125px;}

#errorbox{
	color:red;
}

#successbox{
}
</style>

<?php 
	function contactus(){
		$form = site_url('home/contactus');
		$captcha = newCaptcha();
		$loader=  loader_image('id="loader_image" class="hidden"'); 
		
		$html = "";
		$html .= "<div id=\"wrap-contactus\">";
		$html .= "<form action=\"{$form}\" id=\"contactus\" name=\"contactus\" method=\"post\" >";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_name')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_name_hint')."'></div>
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='name' id='name' maxlength='45' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_email')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_email_hint')."'></div>	
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='email' id='email' maxlength='45' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_mobile')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_mobile_hint')."'></div>	
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='mobile' id='mobile' maxlength='45' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_subject')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_subject_hint')."'></div>	
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='subject' id='subject' maxlength='145' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_message')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_message_hint')."'></div>	
				</div>";
		$html .= "<div class=\"input-field\"><textarea class='message' name='message' id='message' maxlength='550' ></textarea></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_captcha')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_captcha_hint')."'></div>	
				</div>";
		$html .= "<div class=\"input-field\">
					<div id=\"captcha-section\">{$captcha}</div> 
					<div id=\"captcha-reload\"></div>
					<div class=\"clrboth\"></div>  
					<div style='float:left;clear:left;margin-top:5px;'>
						<input type='text' name='captcha' id='captcha' maxlength='15' />
					</div>
				</div>";
		$html .= "</div>";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field\">
					<input type='submit' class='save-button' name='send' id='send' value='".language_translate('contact_sys_send')."' />
					{$loader}
				</div>";
		$html .= "</div>"; 
		
		$html .= "</form>";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field hidden\" id='errorbox'></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field hidden\" id='successbox'></div>";
		$html .= "</div>"; 
		
		$html .= "</div>";
		
		$html .= "<script type='text/javascript'>
				$(document).ready(function(){
					var option = { 
							beforeSubmit:  validateBeforeSubmit,  
							success: processAfterSubmit
						};	
					$('#contactus').ajaxForm(option);
					$('.help-text[title]').qtip({ style: { name: 'dark', tip: true } });
				});
				function validateBeforeSubmit(formData, jqForm, options){
					$('#successbox,#errorbox').hide();
					$('#loader_image').toggle();
					return true;
				}
				function processAfterSubmit(responseText, statusText, xhr, form){
					var obj = jQuery.parseJSON( responseText );
					 
					$('#loader_image').toggle();
					if(obj.result == 'ok'){
						$('#successbox').html(obj.msg).show();
					    $('#contactus')[0].reset();   
					}else{
						$('#errorbox').html(obj.msg).show();
					}
				}
			</script>
		";
		
		return $html;
	}

    function support_message(){
        $form = site_url('agent/async/submit_send_message');
        $loader=  loader_image('id="loader_image" class="hidden"'); 
        $AGENT = getAccountUserObject();
        $user_id = $AGENT->getId();
        
        $html = "";
		$html .= "<div id=\"wrap-contactus\">";
		$html .= "<form action=\"{$form}\" id=\"submit_send_message\" name=\"submit_send_message\" method=\"post\" >";
		
        $html .= "<input type=\"hidden\" name=\"user_id\" id=\"user_id\" value=\"$user_id\" />";
        
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_message')."</label>
					<div class=\"help-text\" title='".language_translate('contact_sys_message_hint')."'></div>	
				</div>";
		$html .= "<div class=\"input-field\"><textarea class='message' name='message_textarea' id='message_textarea' maxlength='550' ></textarea></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field\">
					<input type='submit' class='save-button' name='send' id='send' value='".language_translate('contact_sys_send')."' />
					{$loader}
				</div>";
		$html .= "</div>"; 
		
		$html .= "</form>";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field hidden\" id='errorbox'></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field hidden\" id='successbox'></div>";
		$html .= "</div>"; 
		
		$html .= "</div>";
		
		$html .= "<script type='text/javascript'>
				$(document).ready(function(){
					var option = { 
							beforeSubmit:  validateBeforeSubmit,  
							success: processAfterSubmit
						};	
					$('#submit_send_message').ajaxForm(option);
					$('.help-text[title]').qtip({ style: { name: 'dark', tip: true } });
				});
				function validateBeforeSubmit(formData, jqForm, options){
					$('#successbox,#errorbox').hide();
					$('#loader_image').toggle();
					return true;
				}
				function processAfterSubmit(responseText, statusText, xhr, form){
					var obj = jQuery.parseJSON( responseText );
					 
					$('#loader_image').toggle();
					if(obj.result == 'ok'){
						$('#successbox').html(obj.msg).show();
					    $('#submit_send_message')[0].reset();   
					}else{
						$('#errorbox').html(obj.msg).show();
					}
				}
			</script>
		";
		
		return $html;
    }
?>
 
<div id="content-left">
	<div id="personal-tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
			<!-- content -->	
			<div class="dashboard-info-wrapper">
				<?php echo support_message();?>
				<div class="clear"></div>
			</div>
			
			
			<!-- end content -->
		</div>
	</div>
</div>
 

<?php $this->load->view('agent/right_nav'); ?>

